/***********************************************
 * Title:       IbatisTeacherDao.java
 * Description: IbatisTeacherDao.java
 * Author:      Niyuzhe
 * Create Date: 2009-12-21
 * CopyRight:   CopyRight(c)@2009
 * Company:     TJUSCS
 * Version:     1.0
 ***********************************************
 */
package edu.tju.teacherManagement;

import java.sql.SQLException;
import java.util.List;

import com.ibatis.sqlmap.client.SqlMapClient;
import com.younker.waf.db.IBatisConfig;

/**
 * @author Niyuzhe
 *
 */
public class IbatisTeacherDao implements ITeacherDao
{

        protected SqlMapClient sqlMap = IBatisConfig.getSqlMapInstance();
        
        /* (non-Javadoc)
         * @see edu.tju.teacherManagement.ITeacherDao#getTeacherById(long)
         */
        public Teacher getTeacherById(long id) throws SQLException
        {
                return (Teacher)sqlMap.queryForObject("getTeacherById", id);
        }

        /* (non-Javadoc)
         * @see edu.tju.teacherManagement.ITeacherDao#getTeacherAnd(edu.tju.teacherManagement.Teacher)
         */
        public List<Teacher> getTeacherAnd(Teacher teacher) throws SQLException
        {
                return sqlMap.queryForList("getTeacherAnd", teacher);
        }

        /* (non-Javadoc)
         * @see edu.tju.teacherManagement.ITeacherDao#getTeacherOr(edu.tju.teacherManagement.Teacher)
         */
        public List<Teacher> getTeacherOr(Teacher teacher) throws SQLException
        {
                return sqlMap.queryForList("getTeacherOr", teacher);
        }

        /* (non-Javadoc)
         * @see edu.tju.teacherManagement.ITeacherDao#insertTeacher(edu.tju.teacherManagement.Teacher)
         */
        public long insertTeacher(Teacher teacher) throws SQLException
        {
                return (Long)sqlMap.insert("insertTeacher", teacher);
        }

        /* (non-Javadoc)
         * @see edu.tju.teacherManagement.ITeacherDao#updateTeacher(edu.tju.teacherManagement.Teacher)
         */
        public long updateTeacher(Teacher teacher) throws SQLException
        {
                return (Integer)sqlMap.update("updateTeacher", teacher);

        }

        /* (non-Javadoc)
         * @see edu.tju.teacherManagement.ITeacherDao#deleteTeacher(long)
         */
        public void deleteTeacher(long id) throws SQLException
        {
                sqlMap.delete("deleteTeacher", id);        
        }

}
